home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- proc int catchdevice(string $dev, string $server)
- {
- return catch( `defineDataServer -d $dev -s $server` );
- }
-
- proc string buildConfigClause(string $config)
- {
- int $debug = 0;
- string $func = "buildConfigClause";
-
- if ($debug) trace(" // config: " + $config + "\n");
-
- // strip off leading white space
- $config = substitute("^[ ]*", $config, "" );
-
- if ( "" != match("^-", $config ) ) {
- if ($debug) trace("// " + $func + ": explicit config option specified\n" );
- return " " + $config + " ";
- }
-
- // Search for the config file in the follow places
- // if absolute path... use it
- // .
- // $MAYA_USER_CONFIG/mocap
- // /usr/aw/userconfig/maya/mocap
- //
- string $configPath[] = { ".",
- "$MAYA_USER_CONFIG/mocap",
- "/usr/aw/userconfig/maya/mocap" };
-
- string $iFoundIt = searchPathArray($config,$configPath);
-
- if ($debug) trace("// " + $func + ": config file :" + $iFoundIt + "\n" );
-
- // set the config flag and return
- if ( $iFoundIt == "" )
- return " ";
-
- return " -c " + $iFoundIt + " ";
- }
-
- global proc int initDataServer(string $dev, string $server, string $host,
- string $config, string $options, int $napTime )
- {
- if (!`licenseCheck -m "edit" -typ "complete"`) {
- return -1;
- }
-
- int $debug = 0;
- int $result = 0; // success
-
- // First check the list of extant devices
- string $devList[] = `listInputDevices`;
- string $aDev;
- for ( $aDev in $devList) {
- if ( $aDev == $dev )
- return $result;
- }
-
- // Now try to define
- if ( catchdevice($dev, $server ) )
- {
- if (`about -evalVersion`)
- {
- // The evaluation version of Maya cannot launch external
- // programs, they will have to launch it themselves.
- //
- error("The dataServer is not running and Maya PLE cannot start it.\n");
- return -1; // failure;
- }
-
- // Ack, we could find it, try to launch..
- if ( $debug ) trace("Server not running, attempt to launch " + $server + "\n");
-
- // $result = -1; // failure
- if ( $host == "localhost" )
- {
- // Build the command string...
- $config = buildConfigClause($config);
- string $cmd = $server + " -d " + $config + $options;
- if (`exists Win32Init`)
- {
- $cmd = "start " + $cmd;
- }
- else
- {
- $cmd = $cmd + " &";
- }
- if ( $debug )
- system("echo \$PATH"); // GG: ignore, debug only
- system( $cmd); // GG: okay for NT
- if ( $napTime > 0)
- {
- // This will take a brief nap, so bring up the wait cursor...
- waitCursor -st true;
-
- if ( $napTime < 10 )
- $napTime = 10;
- $cmd = "sleep " + $napTime;
- system( $cmd); // GG: need "sleep" for NT
-
- // We have awakened...
- waitCursor -st false;
- }
- if ( catchdevice($dev, $server ) )
- {
- $result = -1; // failure
- }
- }
- else // we could support remote launch here...
- $result = -1; // failure
- }
- return $result;
- }
-